// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import VueRouter from 'vue-router'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import Vuex from 'vuex'
import store from './store'
//导入全局样式表
import './assets/css/global.css'

import axios from 'axios'

Vue.use(VueRouter);
Vue.use(ElementUI);
Vue.use(Vuex);
//添加到vue.prototype.$http后,可以在每一个组件上通过
// this.$http获取axios 不必每个页面都
// import  axios   $http是自定义的属性名,可以随便起
axios.defaults.baseURL='http://127.0.0.1:8888/api/private/v1/'//配置请求根路径

//通过axios请求拦截器添加token,保证拥有获取数据的权限
//axiso请求拦截
axios.interceptors.request.use(config=>{

//为请求头对象，添加Token验证的Authorization字段
config.headers.Authorization=window.sessionStorage.getItem('token');

console.log(config)

//在最害必须return config
return config 

})


Vue.prototype.$http=axios;



Vue.config.productionTip = false



/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)

})
